/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.colswe.testingProject.view;

import org.colswe.testingProject.entity.SystemRoles;

/**
 *
 * @author andres
 */
public class PrincipalFrame extends javax.swing.JFrame {

    private SystemRoles role;
    
    /**
     * Creates new form PrincipalFrame
     */
    public PrincipalFrame(SystemRoles role) {
        this.role = role;
        initComponents();
        if(this.role.getName().equals("Administrador en el sistema")){
            btnApplicationCreate.setEnabled(false);
            btnApplicationSearch.setEnabled(false);
        }
        if(this.role.getName().equals("Secretaria de la Coordinación Curricular")){
            btnAdminUsers.setEnabled(false);
        }
        if(this.role.getName().equals("Asistente de la Coordinación Curricular")){
            btnAdminUsers.setEnabled(false);
            btnApplicationCreate.setEnabled(false);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlOptions = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnAdminUsers = new javax.swing.JButton();
        btnApplicationCreate = new javax.swing.JButton();
        btnApplicationSearch = new javax.swing.JButton();
        btnExit = new javax.swing.JButton();
        btnLogOut = new javax.swing.JButton();
        pnlPricipal = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Bienvenido");
        setMaximumSize(new java.awt.Dimension(1000, 650));
        setMinimumSize(new java.awt.Dimension(1000, 650));
        setName("Frame1");
        setPreferredSize(new java.awt.Dimension(1000, 650));

        pnlOptions.setBackground(java.awt.Color.lightGray);
        pnlOptions.setMaximumSize(new java.awt.Dimension(270, 650));
        pnlOptions.setMinimumSize(new java.awt.Dimension(270, 650));
        pnlOptions.setPreferredSize(new java.awt.Dimension(270, 650));

        jLabel1.setFont(new java.awt.Font("Cantarell", 0, 18)); // NOI18N
        jLabel1.setText("Bienvenido");

        btnAdminUsers.setText("Administrar Usuarios");
        btnAdminUsers.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdminUsersActionPerformed(evt);
            }
        });

        btnApplicationCreate.setText("Radicar Solicitud");
        btnApplicationCreate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnApplicationCreateActionPerformed(evt);
            }
        });

        btnApplicationSearch.setText("Buscar Solicitud");
        btnApplicationSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnApplicationSearchActionPerformed(evt);
            }
        });

        btnExit.setText("Salir");
        btnExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExitActionPerformed(evt);
            }
        });

        btnLogOut.setText("Cerrar Sesión");
        btnLogOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLogOutActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlOptionsLayout = new javax.swing.GroupLayout(pnlOptions);
        pnlOptions.setLayout(pnlOptionsLayout);
        pnlOptionsLayout.setHorizontalGroup(
            pnlOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlOptionsLayout.createSequentialGroup()
                .addGroup(pnlOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlOptionsLayout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addGroup(pnlOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel1)
                            .addComponent(btnAdminUsers)
                            .addComponent(btnApplicationCreate)
                            .addComponent(btnApplicationSearch))
                        .addGap(0, 43, Short.MAX_VALUE))
                    .addGroup(pnlOptionsLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnExit)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnLogOut)))
                .addContainerGap(12, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pnlOptionsLayout.setVerticalGroup(
            pnlOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlOptionsLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(btnAdminUsers)
                .addGap(18, 18, 18)
                .addComponent(btnApplicationCreate)
                .addGap(18, 18, 18)
                .addComponent(btnApplicationSearch)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 384, Short.MAX_VALUE)
                .addGroup(pnlOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnExit)
                    .addComponent(btnLogOut))
                .addGap(54, 54, 54))
        );

        pnlPricipal.setMaximumSize(new java.awt.Dimension(730, 650));
        pnlPricipal.setMinimumSize(new java.awt.Dimension(730, 650));
        pnlPricipal.setPreferredSize(new java.awt.Dimension(730, 650));
        pnlPricipal.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnlOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlPricipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlPricipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAdminUsersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdminUsersActionPerformed
        pnlPricipal.setVisible(false);
        pnlPricipal.removeAll();
        pnlPricipal.add(new UserAdministration());
        pnlPricipal.setVisible(true);
    }//GEN-LAST:event_btnAdminUsersActionPerformed

    private void btnLogOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogOutActionPerformed
        java.awt.EventQueue.invokeLater(new Runnable() {
            
            @Override
            public void run() {
                new LogInWindow().setVisible(true);
            }
        });
        this.dispose();
    }//GEN-LAST:event_btnLogOutActionPerformed

    private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnExitActionPerformed

    private void btnApplicationCreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplicationCreateActionPerformed
        pnlPricipal.setVisible(false);
        pnlPricipal.removeAll();
        pnlPricipal.add(new ApplicationPanel());
        pnlPricipal.setVisible(true);
    }//GEN-LAST:event_btnApplicationCreateActionPerformed

    private void btnApplicationSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplicationSearchActionPerformed
        pnlPricipal.setVisible(false);
        pnlPricipal.removeAll();
        pnlPricipal.add(new ApplicationSearch());
        pnlPricipal.setVisible(true);
    }//GEN-LAST:event_btnApplicationSearchActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdminUsers;
    private javax.swing.JButton btnApplicationCreate;
    private javax.swing.JButton btnApplicationSearch;
    private javax.swing.JButton btnExit;
    private javax.swing.JButton btnLogOut;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel pnlOptions;
    private javax.swing.JPanel pnlPricipal;
    // End of variables declaration//GEN-END:variables
}
